home *** CD-ROM | disk | FTP | other *** search
- DEFINT A-Z
- DECLARE SUB YNQvertical (dLine, dCol, decision$)
- DECLARE SUB YNQhorizontal (dLine, dCol, decision$)
-
- ' Shareware : If you find it useful, register it for $10, I'll keep you
- ' posted on additions and improvements and keep you up to date on exciting
- ' developments in the explosive shareware field.
- '
- ' Your registration encourages the concept of computer software you
- ' can 'try' before you 'buy.'
- '
-
- ' ██████████████
- ' █┌───────────────┐
- ' █│ YNQfra.bas │█ ' gets a yes, no or quit decision from
- ' └───────────────┘█ ' the operator...choose either a hori-
- ' ███████████████ ' zontal or vertical presentation.
- '
- ' Interesting 3D effect in an entirely
- ' text based screen mode.
- '
- ' Several other grid types are included
- ' in the source code if you prefer a
- ' more 'minimalist' approach to getting
- ' the decision on crowded screens.
- '
- ' Author: Kirk Woodward d/b/a
- ' People Centered Programs
- ' PO Box 610171
- ' Dallas, TX 75261-0171
- ' Voice: 817/488-4940
- ' FAX: 817/488-4945
- ' CompuServe: 70146,51
- '
- '
-
- CLS
-
- PRINT , "Enter the line and column you want the"
- PRINT , "decision grid to be displayed on. Separate"
- PRINT , "the values with a comma: Example: 10,15"
- PRINT , "will put the grid on the 10th line, at the"
- PRINT , "15th column. "
- PRINT
- PRINT , ; : INPUT dLine, dCol
- PRINT
- LOCATE , , 1, 1, 8: PRINT , "<H>orizontal or <V>ertical display? ";
-
-
- DO
-
- do$ = UCASE$(INPUT$(1))
-
- COLOR 0, 7
-
- SELECT CASE do$
-
- CASE "H"
- CALL YNQhorizontal(dLine, dCol, decision$)
-
- CASE "V"
- CALL YNQvertical(dLine, dCol, decision$)
-
- CASE ELSE
- SOUND 800, 3: BEEP
- do$ = ""
-
- END SELECT
-
- LOOP UNTIL do$ = "H" OR do$ = "V"
-
- COLOR 7, 0
-
- CLS
-
- LOCATE 3, 10: PRINT " "; decision$; " was returned to calling program. (Any key continues.) "
- PRINT
-
- SLEEP
-
-
-
- PRINT , "If you find these routines helpful or instructive . . ."
- PRINT
- PRINT , " Register by sending $10 to:"
- PRINT
- PRINT , " People Centered Programs"
- PRINT , " PO Box 610171"
- PRINT , " Dallas, TX 75261-0171"
- PRINT , " CompuServe: 70146,51"
- PRINT
- PRINT " Your registration puts you 'in loop' in the exciting field of Shareware"
- PRINT " and encourages the flow of solid useful computer software that you"
- PRINT " can 'try before you buy.'"
- PRINT
- PRINT , "Re-start this demo by"
- PRINT , "holding down the Shift key while"
- PRINT , "tapping the F5 key twice. "
- PRINT
- PRINT , "Touch any key to see"
- PRINT , "the source code."
-
-
- END ' re-start the demo with: Shift+F5
-
- SUB YNQhorizontal (dLine, dCol, decision$)
-
- ' dLine and dCol are the upper left corner of the grid, it is drawn down
- ' and to the right of this point
- '
- ' decision$ is used to return the operator's decision to the program.
-
- ' This SUB responds to left and right arrow keys, down arrow key,
- ' the enter key and
- ' touching a Y, N or Q
-
- ' if the line and column values requested will crash the SUB,
- ' we change them here. The box needs five lines and 28 columns
-
- IF dLine < 5 THEN dLine = 1
- IF dLine > 21 THEN dLine = 21
- IF dCol < 1 THEN dCol = 1
- IF dCol > 51 THEN dCol = 51
-
- ' turn off the cursor
-
- LOCATE , , 0
-
-
- ' Now draw the frame...
-
- DIM L$(1 TO 5)
- COLOR 15, 0
-
- ' here are different box styles. Change your default design by use
- ' of the remark symbol - the ' (apostrophy)
- '
-
- 'L$(1) = "┌───────────────────────╖ "
- 'L$(2) = "│∙╔═══╤═══╤═══╤═══╤═══╕∙║ "
- 'L$(3) = "│ ║ │ Y │ N │ Q │ │ ║ "
- 'L$(4) = "│∙╙───┴───┴───┴───┴───┘∙║ "
- 'L$(5) = "╘═══════════════════════╝ "
-
- '
- ' the following is the default grid - the most elaborate of the
- ' series. If you want to use any of the others the placement
- ' of the arrows and the movement of the highlighted selections
- ' will need to be adjusted a few spaces in the SELECT CASE block
- ' below.
- '
- ' Remove the ' marks from in front of the grid you want to use
- ' put ' marks in front of this one and then run, making notes as
- ' to how many spaces left or right each feature needs to move.
- '
- L$(1) = "┌───────────────────────────╖"
- L$(2) = "│∙╔═══╕╔═══╕╔═══╕╔═══╕╔═══╕∙║"
- L$(3) = "│ ║ │║ Y │║ N │║ Q │║ │ ║" ' maxed out
- L$(4) = "│∙╙───┘╙───┘╙───┘╙───┘╙───┘∙║"
- L$(5) = "╘═══════════════════════════╝"
-
- 'l$(1) = ""
- 'l$(2) = "╔═══╤═══╤═══╤═══╤═══╗"
- 'l$(3) = "║ │ Y │ N │ Q │ ║"
- 'l$(4) = "╚═══╧═══╧═══╧═══╧═══╝"
- 'l$(5) =""
-
- 'l$(1) = ""
- 'l$(2) = "┌───┬───┬───┬───┬───┐"
- 'l$(3) = "│ │ Y │ N │ Q │ │"
- 'l$(4) = "└───┴───┴───┴───┴───┘"
- 'l$(5) = ""
-
- 'l$(1) = ""
- 'l$(2) = "╔═╦═╦═╕"
- 'l$(3) = "║Y║N║Q│" ' minimal, drops arrows too.
- 'l$(4) = "╙─╨─╨─┘" ' need to rework much of rest of sub.
- 'l$(5) = ""
-
- 'l$(1) = ""
- 'l$(2) = "┌───┬───╥───╥───╥───┐"
- 'l$(3) = "│ │ Y ║ N ║ Q ║ │"
- 'l$(4) = "└───╘═══╩═══╩═══╩───┘"
- 'l$(5) =""
-
-
- 'l$(1) =""
- 'l$(2) = "┌───╥───╥───╥───╥───╖"
- 'l$(3) = "│ ║ Y ║ N ║ Q ║ ║"
- 'l$(4) = "╘═══╩═══╩═══╩═══╩═══╝"
- 'l$(5) = "" 2
-
- dLine = dLine - 1 ' adjusts the line where the box starts to print
- ' . . . one line above the letters
-
- ' If you have access to MS PDS 7.1, then this is the place where
- ' you would want to use that portion of the User Interface that
- ' captures the portion of the screen you are about to overwrite,
- ' then restore it before leaving the SUB. Three items are needed:
- '
- ' 1. getBackground SUB from WINDOWS.BAS
- ' 2. putBackground SUB from WINDOWS.BAS
- ' 3. uiasm.qlb or lib library from \bc7\lib
- ' (Assuming you used MicroSoft's default names when installing)
- '
- ' -- Those two SUBS call an assembly language routine
- ' contained in \BC7\LIB subdirectory, (uiasm.lib) which needs to be
- ' loaded at startup with the command:
- '
- ' qbx /runProgramName /l\bc7\lib\uiasm
- ' you don't need to
- ' type a file extension
- ' for uiasm. QBX will load
- ' the right version (.QLB
- ' is for use in QBX, .LIB
- ' is called by compiler.
- '
-
- FOR d = 1 TO 5
- LOCATE dLine + d, dCol: PRINT L$(d); ' print a line of the grid
- IF d = 3 THEN dataLine = CSRLIN ' remember the line the Y N Q
- ' and the arrows will go on.
- NEXT d
-
- COLOR 16, 7 ' we blink arrows and default till a key is pressed.
-
- LOCATE dataLine, dCol + 3: PRINT CHR$(27); ' a left arrow
- LOCATE dataLine, dCol + 25: PRINT CHR$(26); ' a right arrow
-
- ' the default decision is " Y " (Yes)
- ' it and the arrows flash to attract operator's attention, quits fla2shing
- ' if an acceptable key is pressed or an arrow key is pressed
-
- LOCATE dataLine, dCol + 8: PRINT " Y ";
-
- highlightedBox = 1 ' the default selection, "Y"
-
- getChoice:
-
- k$ = ""
-
- DO
- k$ = INKEY$ ' capture operator's key stroke(s)
- LOOP UNTIL k$ > ""
-
- ' no need to flash the arrows any more
-
- COLOR 0, 7
- LOCATE dataLine, dCol + 3: PRINT CHR$(27); ' a left arrow
- LOCATE dataLine, dCol + 25: PRINT CHR$(26); ' a right arrow
- COLOR 7, 0
-
-
- acceptDownArrowReturnPoint:
-
- ' if the operator presses the down arrow
- ' we treat it as a selection, the ENTER key
-
-
- SELECT CASE LEN(k$)
-
- CASE 1 ' a regular key was touched
-
- SELECT CASE UCASE$(k$)
-
- CASE CHR$(13) ' operator has pressed ENTER key
- IF highlightedBox = 1 THEN decision$ = "Y"
- IF highlightedBox = 2 THEN decision$ = "N"
- IF highlightedBox = 3 THEN decision$ = "Q"
-
- CASE "Y"
- decision$ = "Y"
- CASE "N"
- decision$ = "N"
- CASE "Q"
- decision$ = "Q"
- CASE ELSE
- ' we ignore all other keys
- SOUND 2200, 1
- GOTO getChoice:
- END SELECT
-
- CASE 2 ' an 'extended' key was touched
-
- SELECT CASE ASC(RIGHT$(k$, 1)) ' get 'meaningful' character
-
- CASE 77 ' right arrow was touched
- highlightedBox = highlightedBox + 1
- IF highlightedBox > 3 THEN highlightedBox = 1
-
- CASE 75 ' left arrow was touched
- highlightedBox = highlightedBox - 1
- IF highlightedBox < 1 THEN highlightedBox = 3
-
- CASE 80 ' down arrow was touched
- ' operators often equate the down arrow with selection
- ' in a situation like this so we accept it as though
- ' the enter key was pressed.
- k$ = CHR$(13)
- GOTO acceptDownArrowReturnPoint:
-
- CASE ELSE
- ' ignore all others
- SOUND 2300, 1
- GOTO getChoice:
-
- END SELECT
-
- SELECT CASE highlightedBox ' the highlighted letter 'moves.'
- CASE 1
- LOCATE dataLine, dCol + 8: COLOR 0, 7: PRINT " Y ";
- LOCATE dataLine, dCol + 13: COLOR 7, 0: PRINT " N ";
- LOCATE dataLine, dCol + 18: COLOR 7, 0: PRINT " Q ";
-
- CASE 2
- LOCATE dataLine, dCol + 8: COLOR 7, 0: PRINT " Y ";
- LOCATE dataLine, dCol + 13: COLOR 0, 7: PRINT " N ";
- LOCATE dataLine, dCol + 18: COLOR 7, 0: PRINT " Q ";
-
- CASE 3
- LOCATE dataLine, dCol + 8: COLOR 7, 0: PRINT " Y ";
- LOCATE dataLine, dCol + 13: COLOR 7, 0: PRINT " N ";
- LOCATE dataLine, dCol + 18: COLOR 0, 7: PRINT " Q ";
-
- END SELECT
-
- GOTO getChoice: ' the highlight has been moved to one
- ' of the three options, we go back to
- ' the INKEY$ routine to see if the
- ' operator wants to select it.
-
- END SELECT
-
- END SUB
-
- SUB YNQvertical (dLine, dCol, decision$)
-
- ' dLine and dCol are the upper left corner of the grid
- ' the grid is drawn down and to the right of this point
- '
- ' decision$ is used to return the operator's decision to program.
-
- ' This SUB responds to left and right arrow keys, the enter key and
- ' touching a Y, N or Q
-
- ' if the line and column values requested will crash the SUB,
- ' we change them here. The box needs 17 lines and 24 columns
-
- IF dLine < 1 THEN dLine = 1
- IF dLine > 8 THEN dLine = 8
- IF dCol < 1 THEN dCol = 1
- IF dCol > 71 THEN dCol = 71
-
- ' turn off the cursor
-
- LOCATE , , 0
-
-
- ' Now draw the frame...
-
- DIM L$(1 TO 17)
- COLOR 15, 0
-
- ' here are different grid styles. Change your default design by use
- ' of the remark symbol - the ' (apostrophy)
- '
- ' Only the first '3d' matrix actually needs seventeen lines to print.
- ' They are blank in the other to maintain consistancy and could
- ' be used for other data, or, the display portion could be reworked
- ' for the exact number of lines needed - one line for each array element
- '
- ' If you would like to have both designs continiously available, then
- ' you would need to pass another parameter:
- '
- ' Example: CALL YNQvertical (dLine, dCol, gridType, decision$)
- '
- ' Where: gridType would be 1 or 2, depending on your choice
- '
- ' the l$() array would also need to become a two dimension array.
- '
- ' Example: DIM l$(2, 17) (Two dimensions with 17 elements each.)
- '
- ' The assignments to the array would be slightly different as well . . .
- '
- ' l$(1,1) = "┌───────╖"
- ' l$(1,2) = "│∙╔═══╕∙║"
- ' l$(1,3) = "│ ║ │ ║"
- ' l$(1,4) = "│ ╙───┘ ║"
- ' .
- ' .
- ' . (and so on for the first design)
- '
- '
- '
- ' l$(2,1) = ""
- ' l$(2,2) = "╔═══╕"
- ' l$(2,3) = "║ │"
- ' l$(2,4) = "╙───┘"
- ' .
- ' .
- ' .
- ' . (and so on for the second design)
- '
- ' Within the 'display loop' you would then have the line:
- '
- ' FOR d = 1 TO 17
- ' LOCATE dLine + d, dCol: PRINT l$(gridType,d);
- ' NEXT d
- '
-
-
-
- L$(1) = "┌───────╖"
- L$(2) = "│∙╔═══╕∙║"
- L$(3) = "│ ║ │ ║"
- L$(4) = "│ ╙───┘ ║"
- L$(5) = "│ ╔═══╕ ║"
- L$(6) = "│ ║ Y │ ║"
- L$(7) = "│ ╙───┘ ║"
- L$(8) = "│ ╔═══╕ ║"
- L$(9) = "│ ║ N │ ║"
- L$(10) = "│ ╙───┘ ║"
- L$(11) = "│ ╔═══╕ ║"
- L$(12) = "│ ║ Q │ ║"
- L$(13) = "│ ╙───┘ ║"
- L$(14) = "│ ╔═══╕ ║"
- L$(15) = "│ ║ │ ║"
- L$(16) = "│∙╙───┘∙║"
- L$(17) = "╘═══════╝"
-
- 'l$(1) = ""
- 'l$(2) = "╔═══╕"
- 'l$(3) = "║ │"
- 'l$(4) = "╙───┘"
- 'l$(5) = "╔═══╕"
- 'l$(6) = "║ Y │"
- 'l$(7) = "╙───┘"
- 'l$(8) = "╔═══╕"
- 'l$(9) = "║ N │"
- 'l$(10) = "╙───┘"
- 'l$(11) = "╔═══╕"
- 'l$(12) = "║ Q │"
- 'l$(13) = "╙───┘"
- 'l$(14) = "╔═══╕"
- 'l$(15) = "║ │"
- 'l$(16) = "╙───┘"
- 'l$(17) = ""
-
- 'l$(5) = "╔═══╕"
- 'l$(6) = "║ Y │"
- 'l$(7) = "╙───┘" ' drops arrows
- 'l$(8) = "╔═══╕"
- 'l$(9) = "║ N │"
- 'l$(10) = "╙───┘"
- 'l$(11) = "╔═══╕"
- 'l$(12) = "║ Q │"
- 'l$(13) = "╙───┘"
-
- 'l$(1) = "╔═╕"
- 'l$(2) = "║Y│"
- 'l$(3) = "╠═╡"
- 'l$(4) = "║N│" ' this is smallest possible presentation - drops
- 'l$(5) = "╠═╡" ' arrows too
- 'l$(6) = "║Q│"
- 'l$(7) = "╙─┘"
-
-
-
-
-
- ' If you have access to MS PDS 7.1, then this is the place where
- ' you would want to use that portion of the User Interface that
- ' captures the portion of the screen you are about to overwrite,
- ' then restore it before leaving the SUB. Three items are needed:
- '
- ' 1. getBackground SUB from WINDOWS.BAS
- ' 2. putBackground SUB from WINDOWS.BAS
- ' 3. uiasm.qlb/lib library from \bc7\lib
- '
- ' -- Those two SUBS call an assembly language routine
- ' contained in \BC7\LIB subdirectory, (uiasm.lib) which needs to be
- ' loaded at startup with the command:
- '
- ' qbx /runProgramName /l\bc7\lib\uiasm
- ' you don't need to
- ' type a file extension
- ' for uiasm. QBX will load
- ' the right version (.QLB
- ' is for use in QBX, .LIB
- ' is called by compiler.
- '
- dLine = dLine - 1 ' adjusts the line where the box starts to print
- ' to accomodate the FOR/NEXT loop incrementing
-
- FOR d = 1 TO 17
- LOCATE dLine + d, dCol: PRINT L$(d);
- NEXT d
-
- COLOR 16, 7
-
- ' display direction arrows within the grid
-
- LOCATE dLine + 3, dCol + 4: PRINT CHR$(24); ' an up arrow
- LOCATE dLine + 15, dCol + 4: PRINT CHR$(25); ' a down arrow
-
- ' the default decision is " Y " (Yes)
- ' it flashes to attract operator's attention, quits flashing
- ' if an acceptable key is pressed or an arrow key is pressed
-
- LOCATE dLine + 6, dCol + 3: PRINT " Y ";
-
- COLOR 7, 0
-
- highlightedBox = 1 ' the default selection, "Y"
-
- getKeyChoice:
-
- k$ = ""
-
- DO
- k$ = INKEY$ ' capture operator's key stroke(s)
- LOOP UNTIL k$ > ""
-
- SELECT CASE LEN(k$)
-
- CASE 1 ' a regular key was touched
-
- SELECT CASE UCASE$(k$)
-
- CASE CHR$(13) ' operator has pressed ENTER key
- IF highlightedBox = 1 THEN decision$ = "Y"
- IF highlightedBox = 2 THEN decision$ = "N"
- IF highlightedBox = 3 THEN decision$ = "Q"
-
- CASE "Y"
- decision$ = "Y"
- CASE "N"
- decision$ = "N"
- CASE "Q"
- decision$ = "Q"
- CASE ELSE
- ' we ignore all other keys
- SOUND 2200, 1
- GOTO getKeyChoice:
- END SELECT
-
- CASE 2 ' an 'extended' key was touched
-
- ' stop arrows from blinking
-
- COLOR 0, 7
- LOCATE dLine + 3, dCol + 4: PRINT CHR$(24); ' an up arrow
- LOCATE dLine + 15, dCol + 4: PRINT CHR$(25); ' a down arrow
- COLOR 7, 0
-
-
- SELECT CASE ASC(RIGHT$(k$, 1)) ' get 'meaningful' character
-
- CASE 80 ' down arrow was touched
- highlightedBox = highlightedBox + 1
- IF highlightedBox > 3 THEN highlightedBox = 1
- CASE 72 ' up arrow was touched
- highlightedBox = highlightedBox - 1
- IF highlightedBox < 1 THEN highlightedBox = 3
-
- CASE ELSE
- ' ignore all others
- SOUND 2300, 1
- GOTO getKeyChoice:
-
- END SELECT
-
- SELECT CASE highlightedBox ' now 'move' the highlight
- CASE 1
- LOCATE dLine + 6, dCol + 3: COLOR 0, 7: PRINT " Y ";
- LOCATE dLine + 9, dCol + 3: COLOR 7, 0: PRINT " N ";
- LOCATE dLine + 12, dCol + 3: COLOR 7, 0: PRINT " Q ";
-
- CASE 2
- LOCATE dLine + 6, dCol + 3: COLOR 7, 0: PRINT " Y ";
- LOCATE dLine + 9, dCol + 3: COLOR 0, 7: PRINT " N ";
- LOCATE dLine + 12, dCol + 3: COLOR 7, 0: PRINT " Q ";
-
- CASE 3
- LOCATE dLine + 6, dCol + 3: COLOR 7, 0: PRINT " Y ";
- LOCATE dLine + 9, dCol + 3: COLOR 7, 0: PRINT " N ";
- LOCATE dLine + 12, dCol + 3: COLOR 0, 7: PRINT " Q ";
-
- END SELECT
-
- GOTO getKeyChoice:
-
- END SELECT
-
- END SUB
-
-